function [P N_Paths] = GetPeak_Indecies(ComingSignal, Th, N_Peaks)

P=[];
a = ComingSignal ;
a(find(a<Th)) = 0;
b=a;
flag = 0;     % 0 for start and 1 for stop
start = 1;
stop = length(b);
count = 1;
for n=1:length(b)-1
    
    if flag == 0 && b(n)<b(n+1)
        start(count) = n;
        flag = 1;
    elseif flag == 1 && b(n) > b(n+1);
        stop(count) = n;
        flag = 0;
        P(count) = find(ComingSignal(start(count):stop(count)) == max(ComingSignal(start(count):stop(count)))) + start(count) -1;
        count = count + 1;
    end
end

if length(P)<N_Peaks
    N_Paths = length(P);
else
    P = P(1:N_Peaks);
    N_Paths = N_Peaks;
end

